package com.jlboot.core.consts;


/**
 * 一万一下都是通用
 * @author wangsanfei
 */
public enum CoreResponseCode {

    SUCCESS(0,"操作成功"),
    FAIL(9,"操作失败"),
    SERVER_ERROR(-1,"服务器错误"),
    ILLEGAL_ARGUMENT_EXCEPTION(-2,"参数错误"),

    //兼容//////////////
    EXPIRED(90,"过期"),
    LOGIN_EXPIRED(91,"登陆已过期"),
    TOKEN_INVALID(92,"无效TOKEN"),
    NO_PERMISSION(93,"没有权限"),
    UN_LOGIN(94,"您未登陆"),
    LOGIN_OUT(95,"登陆已注销"),
    ACCOUNT_LOCK(96,"账户被锁定"),
    PASSWORD_ERR(97,"账号或密码错误"),
    ACCOUNT_NOT_EXIST(98,"账号不存在"),
    VER_CODE_ERR(99,"验证码错误"),
    UN_KNOW_ERR(999999999,"未知错误"),


    ;
    // 普通方法
    public static CoreResponseCode getByCode(Integer Code) {
        for (CoreResponseCode c : CoreResponseCode.values()) {
            if (c.getCode().equals(Code)) {
                return c;
            }
        }
        return null;
    }
    // 普通方法
    public static CoreResponseCode getName(String name) {
        for (CoreResponseCode c : CoreResponseCode.values()) {
            if (c.getName().equals(name)) {
                return c;
            }
        }
        return null;
    }

    private Integer code;
    private String name;

    CoreResponseCode(Integer code,String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

}
